<template>
	<div style="">
  <top-nav bgColor="white" title="发送授权单"  @fatherTitle="sendSms" :isCenterBtn="true"  :rightShow="true" returnPath="hongchangLaddingBills" btnName="作废" @fatherDo="unselect" ></top-nav>
   <section style="width: 100%;display: flex;flex-direction: column;background-color: white;padding:0.4rem 0.6rem;" @click="sendDetailsParam()">
			<section style="justify-content: left;align-items: center;display: flex;flex-direction: row;height: 2.8rem;padding: 0 0.5rem;">

				<!--<mu-icon style="flex: 1;" value="keyboard_arrow_right" :size="26"/>-->
			</section>
			<section style="display: flex;flex-direction: column;justify-content: center;justify-content: left;padding: 0 0.5rem;">
				<span style="text-align: left;font-size: 1.1rem;">单据编号：{{bill.BillNo}}</span>
				<span  class="card-item-child">客户：{{bill.CustomName}}</span>
				<span class="card-item-child">车牌号：{{bill.CarNo}}</span>
				<span class="card-item-child">备注：</span>
				<span class="card-item-child">物料：{{bill.ItemName}}</span>
				<span class="card-item-child">提货码：{{bill.DeliveryCode}}</span>
				<span class="card-item-child">预装量：{{bill.QtyPln}}</span>
				<span class="card-item-child">提货方式：自提</span>
				<span class="card-item-child">创建时间：{{bill.TimeRht}}</span>
			</section>
			
  </section>
	  <mu-table multiSelectable enableSelectAll ref="table" :showCheckbox="false"  style="padding: 0 0.6rem;">
    <mu-thead>
      <mu-tr style="">
        <mu-th style="font-size: 1rem;color:#0090FF;height: 2rem;">账户编号</mu-th>
        <mu-th style="font-size: 1rem;color:#0090FF;height: 2rem;">暂扣量</mu-th>
        <mu-th style="font-size: 1rem;color:#0090FF;height: 2rem;">价格</mu-th>
      </mu-tr>
    </mu-thead>
    <mu-tbody >
      <mu-tr v-for="item in bill.OrderList" :key = "item.ID">
        <mu-td style="height: 1.2rem;">{{item.OrderNo}}</mu-td>
        <mu-td>{{item.QtyAllot}}</mu-td>
        <mu-td>{{item.Price}}</mu-td>
      </mu-tr>
    </mu-tbody>
  </mu-table>
  
  <mu-dialog :open="isPop" title="提示" @close="close">
            此操作将作废本次任务单, 是否作废?
    <mu-flat-button slot="actions" @click="close('cancel')" primary label="取消"/>
    <mu-flat-button slot="actions" primary @click="close('sure')" label="确定"/>
  </mu-dialog>
  
  
	</div>
</template>

<script>
	import TopNav from '@/components/nav/topNav.vue'
	export default {
		components: {
     			 TopNav
  		},
	  	data(){
  	  	return{
  	  		bill:{},
  	  		isPop:false
  	  		}
 		},
  		mounted(){
  	  		console.info(this.$route.params.billNo)
  	  		this.bill=this.$route.params.bill
  	  		this.getSalesBill()
  		},	
	  methods: {
	  	close(val){
	    	if(val=='sure'){
	    		this.cancleTask()
	    	}
	    	this.isPop=false
	    },
	 	unselect(){
	 		this.isPop=true
//  	let that=this
// 	   this.$confirm('此操作将作废本次任务单, 是否作废?', '提示', {
//        confirmButtonText: '确定',
//        cancelButtonText: '取消',
//        center:true,
//        type: 'warning'
//     }).then(() => {
//      		that.cancleTask()
//      }).catch(() => {        
//     });
   	 },
    	sendSms(){
   		 var u = navigator.userAgent;
    	 var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
    	 var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
		 var msg   		
    	if(isAndroid){
    		msg='sms:?body='+this.bill.CarNo+'的车主您好，请到'+localStorage.factoryName+'提货，品种：'+this.bill.ItemName+'，预装量：'+this.bill.QtyPln+'吨，'+'提货码：'+this.bill.DeliveryCode+'#mp.weixin.qq.com'
    	}else{
    	    msg='sms:&body='+this.bill.CarNo+'的车主您好，请到'+localStorage.factoryName+'提货，品种：'+this.bill.ItemName+'，预装量：'+this.bill.QtyPln+'吨，'+'提货码：'+this.bill.DeliveryCode

    	}
		 window.location.href = msg
		},

		getSalesBill(){
			let that=this
			that.axios.post('/hongchang/getSalesBill',{
				'factoryId':localStorage.factoryId,
				'uid':localStorage.uid,
				'ID':this.bill.ID,
				'ItemID':this.bill.ItemID
				}).then(function(response){
					console.info(response.data)
					that.bill=response.data.data
					console.info(this.list)
				}).catch(function(error){
						
				})	
		},
		cancleTask(){
			let that=this
			that.axios.post('/hongchang/cancleTask',{
				'factoryId':localStorage.factoryId,
				'uid':localStorage.uid,
				'fid':this.bill.ID,
				'ItemID':this.bill.ItemID
				}).then(function(response){
					console.info(response.data)
					that.$message({type: 'success',message: '作废成功!',duration:1500})
          			that.$router.replace({path:'hongchangLaddingBills'})
					
				}).catch(function(error){
					that.$message({type: 'info',message: '作废失败',duration:1500});
				})	
			
		}
		}
	}
</script>

<style>
		.card-item-child{
		text-align: left;
		font-size: 0.9rem;
		height: 1.6rem;
		color: #939393;
	}
</style>